<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div>
    <el-form ref="form" :model="s_search" :rules="rules" label-width="100px" id="mvcfm">
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="类别名称" prop="pro_name">
              <el-input v-model="s_search.pro_name" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="搜索" prop="">
              <a href="javascript:mvc.submitURL('gotoPage('/mes/product/ProductClassTech?')')" type='primary'>{{s_search['']}}</a>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="popAddProductClassTec('')" type='success' size="mini"><i class='fa fa-plus'></i>增加产品类别</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 产品类别 </span>
      </div>
      <el-table :data="p_category">
        <el-table-column label="" prop="category_id" width="80">
          <template slot-scope="scope">
            <el-button @click="$parent.$parent.closeProductClassTech(scope.row['category_id'],scope.row['pro_name']);" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
          </template>
        </el-table-column>
        <el-table-column label="#" align="center" type='index'>
        </el-table-column>
        <el-table-column label="产品类别" prop="pro_name">
        </el-table-column>
        <el-table-column label="操作" prop="">
          <template slot-scope="scope">
            <el-link @click="d_pro('&CMID4='+scope.row.category_id+'')" type='danger'>删除</el-link>
            <el-link @click="gotoPage('/mes/product/UpProductClassTec?CMIDcategory_id='+scope.row.category_id+'&cpopup=reload'+vueparams+'')" type='success'>修改</el-link>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
    </el-form>
    <el-dialog :visible.sync="AddProductClassTecVisible" append-to-body>
      <AddProductClassTec v-if="AddProductClassTecVisible" ref="AddProductClassTec" :popparams="popparams"> </AddProductClassTec>
    </el-dialog>
    <el-dialog :visible.sync="UpProductClassTecVisible" append-to-body>
      <UpProductClassTec v-if="UpProductClassTecVisible" ref="UpProductClassTec" :popparams="popparams"> </UpProductClassTec>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import AddProductClassTec from "@/views/mes/product/AddProductClassTec";
  import UpProductClassTec from "@/views/mes/product/UpProductClassTec";
  export default {
    name: 'ProductClassTech',
    components: {
      AddProductClassTec,
      UpProductClassTec,
    },
    props: ['popparams'],
    data() {
      return {
        AddProductClassTecVisible: false,
        AddProductClassTecValue: null,
        AddProductClassTecDesc: null,
        UpProductClassTecVisible: false,
        UpProductClassTecValue: null,
        UpProductClassTecDesc: null,
        vueparams: this.getVUEParams(""),
        s_search: {
          pro_name: null,
        },
        p_category: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/product/TechnologyAction/productClassTech?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_pro(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/product/TechnologyAction/d_pro?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popAddProductClassTec(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.AddProductClassTecVisible = !this.AddProductClassTecVisible;
      },
      popUpProductClassTec(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.UpProductClassTecVisible = !this.UpProductClassTecVisible;
      },
    },
  }
</script>
